package com.whfc.ms.api.md.service.impl;

import com.whfc.base.dto.AppWeatherDTO;
import com.whfc.base.service.WeatherService;
import com.whfc.common.result.PageData;
import com.whfc.env.dto.EnvDataLogAnalysisDTO;
import com.whfc.env.dto.EnvDustDTO;
import com.whfc.env.dto.EnvDustDataDTO;
import com.whfc.env.dto.EnvWarnRecordDTO;
import com.whfc.env.service.EnvDataService;
import com.whfc.env.service.EnvDeviceService;
import com.whfc.env.service.EnvWarnDataService;
import com.whfc.ms.api.md.service.MdEnvBoardService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @author qzexing
 * @version 1.0
 * @date 2021/11/22 10:10
 */
@Service
public class MdEnvBoardServiceImpl implements MdEnvBoardService {

    @DubboReference(interfaceClass = EnvDeviceService.class, version = "1.0.0")
    private EnvDeviceService envDeviceService;

    @DubboReference(interfaceClass = EnvDataService.class, version = "1.0.0")
    private EnvDataService envDataService;

    @DubboReference(interfaceClass = EnvWarnDataService.class, version = "1.0.0")
    private EnvWarnDataService envWarnDataService;

    @DubboReference(interfaceClass = WeatherService.class, version = "1.0.0")
    private WeatherService weatherService;

    @Override
    public List<EnvDustDTO> deviceList(Integer deptId) {
        return envDeviceService.deviceList(deptId, null, null);
    }

    @Override
    public EnvDustDataDTO getLatestData(Integer dustId) {
        return envDataService.getDustData(dustId);
    }

    @Override
    public List<EnvDustDataDTO> getDustDataLog(Integer dustId, Date startTime, Date endTime) {
        return envDataService.getDustDataLog(dustId, startTime, endTime);
    }

    @Override
    public EnvDataLogAnalysisDTO airDataLogAnalysis(Integer dustId, String type, Date startTime, Date endTime) {
        return envDataService.customizeDataLogAnalysis(dustId, Collections.singletonList(type), startTime, endTime);
    }

    @Override
    public PageData<EnvWarnRecordDTO> getEnvDeviceWarnRecordList(Integer dustId, Integer ruleType, Integer pageNum,
                                                                 Integer pageSize, Date startTime, Date endTime) {
        return envWarnDataService.getEnvDeviceWarnRecordList(dustId, ruleType, pageNum, pageSize, startTime, endTime);
    }

    @Override
    public List<AppWeatherDTO> getWeatherList(Integer deptId) {
        return weatherService.getWeekWeatherList(deptId);
    }
}
